﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

public partial class UserAudits : Acms.AcmsControls.ContentControls.Admin.BaseCustomAdminControl
{
    private CarbonExchange.Bll.UserAuditFactory _factory;
    protected CarbonExchange.Bll.UserAuditFactory Factory
    {
        get 
        {
            if (_factory == null)
                _factory = new CarbonExchange.Bll.UserAuditFactory();
            return _factory;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            grid.VirtualItemCount = Factory.GetTotal(null, AcmsContext.SiteId);
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        ds.Select += new EventHandler<Acms.DataControls.EventDrivenDataSourceSelectEventArgs>(ds_Select);
        grid.MasterTableView.Columns.OfType<GridHyperLinkColumn>().Where(x => x.Text == "View").Single().DataNavigateUrlFormatString = base.ResolveCustomControlPath("~/UserAuditList.ascx?Id={0}");
    }

    void ds_Select(object sender, Acms.DataControls.EventDrivenDataSourceSelectEventArgs e)
    {
        e.SetData(Factory.Search(null, AcmsContext.SiteId, grid.MasterTableView.SortExpressions.GetSortString(), grid.CurrentPageIndex, grid.PageSize));
    }
}
